﻿var HomeSmartAfterHours = {
	Init: function () {
		this.ResizeMain();
		$("#CheckMessage").attr("src", "CheckMessage.asp");

	},

	/*------------------------------------------------------------------*/
	InitHandlers: function () {
		window.onresize = function () {
			HomeSmartAfterHours.ResizeMain();
		}

		/*-------------------*/
		$("#BtnHelp").click(function () {
			HomeSmartAfterHours.OpenHelp();
		});

		/*--------------------------------------------*/
		$("#BtnScripts").click(function () {
			var state = this.getAttribute("state");

			if (state == "Down") {
				state = "";
				HomeSmartAfterHours.HideScriptsWindow($(this));
			}
			else {
				state = "Down";
				HomeSmartAfterHours.ShowScriptsWindow($(this));
			}

		});
	},

	/*------------------------------------------------------------------*/
	OpenHelp: function () {
		url = "Help.html"
		title = "Help"
		params = "width=900,height=500,status=no"
		popup = window.open(url, title, params)
	},

	/*------------------------------------------------------------------*/
	ResizeMain: function () {
		var ifrm = document.getElementById("main");
		var docHeight = document.documentElement.clientHeight;
		ifrm.height = (docHeight - 55);
	},

	/*------------------------------------------------------------------*/
	SetNavButton: function (button) {
		document.getElementById("BtnSearch").src = "Content/Images/NavButtonSearch.png"
		document.getElementById("BtnOperator").src = "Content/Images/NavButtonOperator.png"
		document.getElementById("BtnDispatch").src = "Content/Images/NavButtonDispatch.png"
		document.getElementById("BtnAdmin").src = "Content/Images/NavButtonAdmin.png"

		if (button && button != "") {
			var btnEL = document.getElementById("Btn" + button);
			var btnDownPath = "Content/Images/NavButton" + button + "Down.png"

			btnEL.src = btnDownPath;
		}
	},

	/*------------------------------------------------------------------*/
	SetTitle: function (title) {
		document.title = title;
	},

	/*------------------------------------------------------------------*/
	ShowScriptsWindow: function (btn) {
		var btn = btn || $("#BtnScripts");

		btn.attr("state", "Down");
		btn[0].src = "Content/Images/NavButtonScriptsDown.png"


		var scriptDialog = $("#scriptDialogChrome");

		scriptDialog.slideDown(100);

		var currentPage = $(ScriptViewer.CurrentPage);
		var loaderFunction = currentPage.attr("loaderFunction");

		ScriptViewer.CheckForContent(currentPage, loaderFunction);

	},

	/*------------------------------------------------------------------*/
	HideScriptsWindow: function (btn) {
		var btn = btn || $("#BtnScripts");

		btn.attr("state", "");
		btn[0].src = "Content/Images/NavButtonScripts.png"


		var scriptDialog = $("#scriptDialogChrome");

		scriptDialog.slideUp(100);
	}

}



/*=========================================================================*/
window.onload = function () {
	HomeSmartAfterHours.Init();
	HomeSmartAfterHours.InitHandlers();

}